package com.ericom.model;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

@Entity
public class Auction extends BaseObject {
	@Override
	public String toString() {
		return new ToStringBuilder(this).append("id", id)
				.append("title", title).append("description", description)
				.append("product", product).append("valideFrom", valideFrom)
				.append("valideTo", valideTo).append("initPrice", initPrice)
				.append("fixedPrice", fixedPrice)
				.append("stepPrice", stepPrice)
				.append("garanteePrice", garanteePrice)
				.append("proofed", proofed).append("status", status).toString();
	}

	@Override
	public boolean equals(final Object other) {
		if (!(other instanceof Auction))
			return false;
		Auction castOther = (Auction) other;
		return new EqualsBuilder().append(id, castOther.id)
				.append(title, castOther.title).isEquals();
	}

	@Override
	public int hashCode() {
		return new HashCodeBuilder().append(id).append(title).toHashCode();
	}

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	@ManyToOne(cascade={CascadeType.REFRESH})
	@JoinColumn(name="product_id")
	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}
@Column(name="valide_from")
	public String getValideFrom() {
		return valideFrom;
	}

	public void setValideFrom(String valideFrom) {
		this.valideFrom = valideFrom;
	}
	@Column(name="valide_to")
	public String getValideTo() {
		return valideTo;
	}

	public void setValideTo(String valideTo) {
		this.valideTo = valideTo;
	}
	@Column(name="init_price")
	public float getInitPrice() {
		return initPrice;
	}

	public void setInitPrice(float initPrice) {
		this.initPrice = initPrice;
	}
	@Column(name="fixed_price")
	public float getFixedPrice() {
		return fixedPrice;
	}

	public void setFixedPrice(float fixedPrice) {
		this.fixedPrice = fixedPrice;
	}
	@Column(name="step_price")
	public float getStepPrice() {
		return stepPrice;
	}

	public void setStepPrice(float stepPrice) {
		this.stepPrice = stepPrice;
	}
	@Column(name="garantee_price")
	public float getGaranteePrice() {
		return garanteePrice;
	}

	public void setGaranteePrice(float garanteePrice) {
		this.garanteePrice = garanteePrice;
	}

	public boolean isProofed() {
		return proofed;
	}

	public void setProofed(boolean proofed) {
		this.proofed = proofed;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	private Long id;
	private String title;
	private String description;
	private Product product;
	private String valideFrom;
	private String valideTo;
	private float initPrice;
	private float fixedPrice;
	private float stepPrice;
	private float garanteePrice;
	private boolean proofed;
	private String status;

}
